﻿import QtQuick


Item{
    id:albumRoot
    property real sideLength
    property real timeLength
    property alias source: coverBody.source
    width: sideLength
    height: sideLength


    Rectangle{
        id:rect
        anchors.fill: parent
        radius: width / 2   //圆形

        //唱片
        Image {
            id:album
            anchors.fill: parent
            fillMode: Image.PreserveAspectFit
            smooth: true
            mipmap: true
            source: "qrc:/images/album.png"
            clip: true

        }

        //音乐封面
        Rectangle{
            id:cover
            anchors.centerIn: album
            width: {
                if(sideLength === undefined){
                    if(albumRoot.width === undefined || albumRoot.height === undefined){
                        return 65
                    }else{
                        return width - 10
                    }
                }
            }

            height: width
            radius: width / 2

            Image{
                id: coverBody
                anchors.centerIn: parent
                fillMode: Image.PreserveAspectFit
                smooth: true

            }
        }



        RotationAnimation{
            id: ani
            duration: timeLength
            loops: Animation.Infinite   //无限循环
        }

    }

    function stopRotation(){
        ani.stop()
    }

    function startRotation(){
        ani.start()
    }
    function restartRotation(){
        ani.restart()
    }
    function pauseRotation(){
        ani.pause()
    }

}
